/*
 * @Author: HeAo
 * @Date: 2022-09-21 10:49:43
 * @LastEditTime: 2022-09-21 15:50:23
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \第二阶段\ES6\day07\3-访问修饰符.ts
 * 别乱动！
 */
// protected修饰符的缺陷 protected实例属性时，子类无法通过super进行访问，protected方法则可以访问
class Person3 {
  public name: string
  protected age: number
  private weight: number
  constructor(name, age, weight) {
    this.name = name;
    this.age = age;
    this.weight = weight
  }

  protected foo() {
    console.log(this.name);
    console.log(this.age);
    console.log(this.weight);
  }
}
class Student3 extends Person3 {
  // constructor(name, age, weight) {
  //   super(name, age, weight)

  // }
  bar() {
    // super 父类的引用
    // console.log(super.name);
    // console.log(super.age);
    // console.log(super.weight);//子类无法访问父类
    super.foo()
    // protected  受保护的，主要针对于受保护的方法
  }
}
let stu3: Student3 = new Student3('terry', 12, 90)
// stu2.bar()
// console.log(stu2.name);
stu3.bar()
// console.log(stu2.age);//为什么报错？受保护 只能在类和子类中访问


